﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$mscb = $_POST["txtMSCB"];
$msbm = $_POST["cboBM"];
$tencb = $_POST["txtTenCB"];
$mk = $_POST["txtMK1"];
$mkmh = md5($mk);

// Kiem tra ma can bo co bi trung hay khong
$queryMSCB = "select MSCB from giang_vien where MSCB = '$mscb'";
$resultMSCB = mysql_query($queryMSCB, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMSCB);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=addgv&info=dupmscb");
}
else
{
	// Them giang vien
	$queryInsGV = "insert into giang_vien(MSCB, MSBM, TEN_CB, MAT_KHAU) values ('$mscb', '$msbm', '$tencb', '$mkmh')";
	mysql_query($queryInsGV, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=addgvsucc");
}

?>